#include "renderer.h"

RRViewport::RRViewport()
{
  n = 0.0;
  f = 1.0;
  width = 640.0;
  height = 480.0;
  ox = 320.0;
  oy = 240.0;
}

void RRViewport::rrViewportTrans(RRPrim *arg)
{
  RRVertex *vp;
  int vnum;
  vnum = arg->rrGetVertsNum();
  for(int i=0; i<vnum; i++) {
    vp = arg->rrGetVertAdrs(i);
    vp->x = (vp->x / vp->w) * (width / 2.0f) + ox;
    vp->y = (vp->y / vp->w) * (height / 2.0f) + oy;
    vp->z = ((f - n) / 2.0f) * (vp->z / vp->w) + (n + f) / 2.0f;
  }
}
